package ua.kharkov.gritsay.net;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import org.jsoup.Connection;
import org.jsoup.Connection.Method;
import org.jsoup.Connection.Response;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

public class GetProxyList {

	public static void main(String[] args) throws IOException {

		//Document doc = null;
		String proxyPost = "/proxy-server-list/anonymous-proxies/";
		String proxyHostUrl = "http://www.proxynova.com";
		
		Map<String, String> cookies = new HashMap<String, String>();
		
		//doc = Jsoup.connect(proxyListUrl).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) "
		//										 + "Chrome/31.0.1650.57 Safari/537.36").get();
		
		//Connection.Response res = Jsoup.connect(proxyListUrl).method(Method.GET).execute();
		
		Connection connectionOne = Jsoup.connect(proxyHostUrl+proxyPost).userAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) " 
										+ "AppleWebKit/537.36 (KHTML, like Gecko) "
										+ "Chrome/31.0.1650.57 Safari/537.36").timeout(1000).method(Method.POST);
		
		for (Entry<String, String> cookie : cookies.entrySet()) {
			connectionOne.cookie(cookie.getKey(), cookie.getValue());
		}
		
		Response responseOne = connectionOne.execute();
		cookies.putAll(responseOne.cookies());
		Document documentOne = responseOne.parse();
						    
		System.out.println(documentOne);
	}
}
